﻿using System;

namespace EmbeddedSharp.Core.Function.String
{
    public class TrimEndNode : FuncNode
    {
        public TrimEndNode()
            : base()
        {
            base.Value = "trimEnd";
        }

        public override object Evaluate()
        {
            int length = Parameters.Count;
            if (length < 1)
            {
                throw new ArgumentException("usage: trimEnd(expr)");
            }

            string expr = Parameters[0].Evaluate().ToString();

            return expr.TrimEnd();
        }
    }
}
